package com.xtayfjpk.spring.security.test;

import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.WebAppContext;

public class Launcher {

	public static void main(String[] args) throws Exception {
		String webApp = "D:\\work\\MyProject\\spring-security-test\\src\\main\\webapp";
		String contextPath = "/spring-security-test";
		WebAppContext context = new WebAppContext(webApp, contextPath);
		
		Server server = new Server(8080);
		
		String keyStorePath = Launcher.class.getResource("/serverKeyStore.jks").getFile();
		String trustStorePath = Launcher.class.getResource("/caKeyStore.p12").getFile();
		SslContextFactory sslContextFactory = new SslContextFactory(keyStorePath);
		sslContextFactory.setNeedClientAuth(true);
		sslContextFactory.setTrustStore(trustStorePath);
		sslContextFactory.setKeyStorePassword("gitblit");
		sslContextFactory.setTrustStorePassword("gitblit");
		sslContextFactory.setTrustStoreType("pkcs12");
		Connector connector = new SslSelectChannelConnector(sslContextFactory);
		connector.setPort(8443);
		
		server.addConnector(connector);
		
		server.setHandler(context);
		server.start();
		
		server.join();
		
		
		
	}

}
